package com.wc.alorithm_blue_bridge._排序.全栈项目小组;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/9/21 19:02
 * @description https://www.lanqiao.cn/problems/19856/learning/?contest_id=207
 */
public class Main {
    /**
     * 排序就得了，贪心
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int n, aLen = 0, bLen = 0;

    public static void main(String[] args) {
        n = sc.nextInt();

        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            char c = sc.next().charAt(0);
            if (c == 'F') a[++aLen] = x;
            else b[++bLen] = x;
        }
        Arrays.sort(a, 1, aLen + 1);
        Arrays.sort(b, 1, bLen + 1);
        int i = 1, j = 1;
        int res = 0;
        while (i <= aLen && j <= bLen) {
            if (a[i] == b[j]) {
                res++;
                i++;
                j++;
            } else if (a[i] < b[j]) i++;
            else j++;
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
